<?	
class CommentsCommon
{	
	private $db_name;	
	
	private function setDbName($db='news_common')
	{
		$this->db_name = $db;		
	}
	
	private function getDbName()
	{
		return $this->db_name;
	}
	
	function __construct($project_id=1, $db='news_common')
	{		
		$this->setDbName($db);
	}

	function getUserCokieNick($cookie_value, $ip)
	{
		$comments_manager = new CommentsCommonManager();
		return $comments_manager->getUserCokieNick($this->getDbName(), $cookie_value, $ip);
	}
	
	function SetUserCokieNick($cookie_value,$ip,$nick)
	{
		$comments_manager = new CommentsCommonManager();
		return $comments_manager->SetUserCokieNick($this->getDbName(), $cookie_value, $ip, $nick);
	}
	
	function selectCommentsByIp($comment_id)
	{
		$comments_manager = new CommentsCommonManager();
		return $comments_manager->selectCommentsByIp($this->getDbName(), $comment_id);
	}
	
	function getCommentReiting($comment_id)
	{
		$comments_manager = new CommentsCommonManager();
		return $comments_manager->getCommentReiting($this->getDbName(), $comment_id);		
	}
	
	function setCommentReiting($comment_id, $increment=0, $ip=0)
	{
		$comments_manager = new CommentsCommonManager();
		$comments_manager->setCommentReiting($this->getDbName(), $comment_id, $increment, $ip);
	}
	
	function getLastCommentId($object_id, $object_type_id, $min_limit)
	{
		$comment_manager = new CommentsCommonManager();
		return $comment_manager->getLastCommentId($object_id, $object_type_id, $min_limit,$this->getDbName());
	}
	
	function getObjectComments($object_id, $object_type_id)
	{
		$comment_manager = new CommentsCommonManager();
		return $comment_manager->getOblectComment($object_id,$object_type_id, $this->getDbName());
	}	
	
	function addComment(&$dialog)
	{		
		$comment_manager = new CommentsCommonManager();
		$id = $comment_manager->addNewComment($dialog, $this->getDbName());
		if ($id)		
		{
			$news_manager = new NewsCommonManager();
			$news_manager->updateNewsReitingCommentsCount($dialog->obj_id,'1',$this->getDbName());
		}
		
		return $id;
	}
	
}
?>